%{
   #include <stdio.h>
   #include "y.tab.h"
%}
%option noyywrap
%option yylineno

/********************TIPOS DE VARIABLE********************/
CHARACTER [Cc][Hh][Aa][Rr][Aa][Cc][Tt][Ee][Rr]|[Cc][Hh][Aa][Rr]
VARCHAR [Vv][Aa][Rr][Cc][Hh][Aa][Rr]
NUMERIC [Nn][Uu][Mm][Ee][Rr][Ii][Cc]
DECIMAL [Dd][Ee][Cc][Ii][Mm][Aa][Ll]
INTEGER [Ii][Nn][Tt]
SMALLINT [Ss][Mm][Aa][Ll]{2}[Ii][Nn][Tt]
FLOAT [Ff][Ll][Oo][Aa][Tt]
REAL [Rr][Ee][Aa][Ll]
DOUBLEPRECISION [Dd][Oo][Uu][Bb][Ll][Ee][ ][Pp][Rr][Ee][Cc][Ii][Ss][Ii][Oo][Nn]
LONGVARCHAR [Ll][Oo][Nn][Gg][Vv][Aa][Rr][Cc][Hh][Aa][Rr]
LONGVARBINARY [Ll][Oo][Nn][Gg][Vv][Aa][Rr][Bb][Ii][Nn][Aa][Rr][Yy]
TIMESTAMP [Tt][Ii][Mm][Ee][Ss][Tt][Aa][Mm][Pp]
DATETIME [Dd][Aa][Tt][Ee][Tt][Ii][Mm][Ee]
TIME [Tt][Ii][Mm][Ee]
DATE [Dd][Aa][Tt][Ee]
OWNER [Oo][Ww][Nn][Ee][Rr]
BIT [Bb][Ii][Tt]
VARBIT [Vv][Aa][Rr][Bb][Ii][Tt]|[Vv][Aa][Rr][Yy][Ii][Nn][Gg][ ][Bb][Ii][Tt]
CLOB [Cc][Ll][Oo][Bb]
BLOB [Bb][Ll][Oo][Bb]
BOOL [Bb][Oo][Oo][Ll]|[Bb][Oo][Oo][Ll][Ee][Aa][Nn]

/*********************CONSTRAINTS*************************/
CHECK [Cc][Hh][Ee][Cc][Kk]
UNIQUE [Uu][Nn][Ii][Qq][Uu][Ee]
NOTNULL [Nn][Oo][Tt][ ][Nn][Uu][Ll][Ll]
PRIMARYKEY [Pp][Rr][Ii][Mm][Aa][Rr][Yy][ ][Kk][Ee][Yy]
FOREIGNKEY [Ff][Oo][Rr][Ee][Ii][Gg][Nn][ ][Kk][Ee][Yy]
REFERENCES [Rr][Ee][Ff][Ee][Rr][Ee][Nn][Cc][Ee][Ss]
IDENTITY [Ii][Dd][Ee][Nn][Tt][Ii][Tt][Yy]
DEFAULT [Dd][Ee][Ff][Aa][Uu][Ll][Tt]
NOACTION [Nn][Oo][ ][Aa][Cc][Tt][Ii][Oo][Nn]
SETDEFAULT [Ss][Ee][Tt][ ][Dd][Ee][Ff][Aa][Uu][Ll][Tt]
CASCADE [Cc][Aa][Ss][Cc][Aa][Dd][Ee]
SETNULL [Ss][Ee][Tt][ ][Nn][Uu][Ll][Ll]
ONDELETE [Oo][Nn][ ][Dd][Ee][Ll][Ee][Tt][Ee]
ONUPDATE [Oo][Nn][ ][Uu][Pp][Dd][Aa][Tt][Ee]

/********COMPARACION******/
IGUALDAD ==?
MAYOROIGUAL >=|=>
MENOROIGUAL <=|=<
DIFERENTE !=|=!|<>

/*******EXTRAS*******/
AND [Aa][Nn][Dd]
OR [Oo][Rr]
XOR [Xx][Oo][Rr]
NOT [Nn][Oo][Tt]
ON [Oo][Nn]
AS [Aa][Ss]

INTNUM [0-9]+
DIGITO [0-9]
CREATE [Cc][Rr][Ee][Aa][Tt][Ee]
DROP [Dd][Rr][Oo][Pp]
ALTER [Aa][Ll][Tt][Ee][Rr]
TRUNCATE [Tt][Rr][Uu][Nn][Cc][Aa][Tt][Ee]
TABLE [Tt][Aa][Bb][Ll][Ee]
INDEX [Ii][Nn][Dd][Ee][Xx]
DATABASE [Dd][Aa][Tt][Aa][Bb][Aa][Ss][Ee]
VIEW [Vv][Ii][Ee][Ww]
PROCEDURE [Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee]
TRIGGER [Tt][Rr][Ii][Gg][Gg][Ee][Rr]
ADD [Aa][Dd][Dd]
COLUMN [Cc][Oo][Ll][Uu][Mm][Nn]
adicional check|unique|"not null"|"primary key"|default
nombre [a-zA-Z_][a-zA-Z0-9_]* 

%%
","    {return(TKN_COMA);}
";"    {return(TKN_PTOCOMA);}
"*"    {return(TKN_MULT);}
"/"    {return(TKN_DIV);}
"+"    {return(TKN_MAS);}
"-"    {return(TKN_MENOS);}
"("    {return(TKN_LP);}
")"    {return(TKN_RP);}
"'"    {return(TKN_COMILLAS);}
"<"    {return(TKN_MENORQUE);}
">"    {return(TKN_MAYORQUE);}
{IGUALDAD} {return(TKN_IGUALDAD);}
{INTNUM} {return(TKN_INTNUM);}
{CHARACTER} {return(TKN_CHARACTER);}
{VARCHAR} {return(TKN_VARCHAR);}
{NUMERIC}  {return(TKN_NUMERIC);}
{DECIMAL}  {return(TKN_DECIMAL);}
{INTEGER}  {return(TKN_INTEGER);}
{SMALLINT}  {return(TKN_SMALLINT);}
{FLOAT}  {return(TKN_FLOAT);}
{REAL}  {return(TKN_REAL);}
{DOUBLEPRECISION}  {return(TKN_DOUBLEPRECISION);}
{LONGVARCHAR} {return(TKN_LONGVARCHAR);}
{LONGVARBINARY} {return(TKN_LONGVARBINARY);}
{TIMESTAMP} {return(TKN_TIMESTAMP);}
{DATETIME} {return(TKN_DATETIME);}
{TIME} {return(TKN_TIME);}
{DATE} {return(TKN_DATE);}
{OWNER} {return(TKN_OWNER);}
{BIT} {return(TKN_TIMESTAMP);}
{VARBIT} {return(TKN_VARBIT);}
{CLOB} {return(TKN_CLOB);}
{BLOB} {return(TKN_BLOB);}
{BOOL} {return(TKN_BOOL);}
{CREATE}    {return(TKN_CREATE);}
{DROP} {return(TKN_DROP);}
{ALTER} {return(TKN_ALTER);}
{TRUNCATE} {return(TKN_TRUNCATE);}
{CHECK} {return(TKN_CHECK);}
{UNIQUE} {return(TKN_UNIQUE);}
{NOTNULL} {return(TKN_NOTNULL);}
{PRIMARYKEY} {return(TKN_PRIMARYKEY);}
{FOREIGNKEY} {return(TKN_FOREIGNKEY);}
{REFERENCES} {return(TKN_REFERENCES);}
{IDENTITY} {return(TKN_IDENTITY);}
{DEFAULT} {return(TKN_DEFAULT);}
{NOACTION} {return(TKN_NOACTION);}
{SETDEFAULT} {return(TKN_SETDEFAULT);}
{CASCADE} {return(TKN_CASCADE);}
{SETNULL} {return(TKN_SETNULL);}
{ONDELETE} {return(TKN_ONDELETE);}
{ONUPDATE} {return(TKN_ONUPDATE);}
{MENOROIGUAL} {return(TKN_MENOROIGUAL);}
{MAYOROIGUAL} {return(TKN_MAYOROIGUAL);}
{DIFERENTE} {return(TKN_DIFERENTE);}
{AND} {return(TKN_AND);}
{OR} {return(TKN_OR);}
{XOR} {return(TKN_XOR);}
{NOT} {return(TKN_NOT);}
{ON} {return(TKN_ON);}
{AS} {return(TKN_AS);}
{TABLE} {return(TKN_TABLE);}
{INDEX} {return(TKN_INDEX);}
{DATABASE} {return(TKN_DATABASE);}
{VIEW} {return(TKN_VIEW);}
{PROCEDURE} {return(TKN_PROCEDURE);}
{TRIGGER} {return(TKN_TRIGGER);}
{COLUMN} {return(TKN_COLUMN);}
{ADD} {return(TKN_ADD);}
{adicional}   {return(TKN_ADICIONAL);}
{nombre}   {return(TKN_NOMBRE);}
\n                      /* ignore end of line */;
[ \t]+                  /* ignore whitespace */;
.      {printf("Error Lexico?!!\n");}
%%
